/**
 * Created by cy on 2021/08/05
 * @description 路由管理
 */
import React from "react";
import { HashRouter, Switch, Route, Redirect  } from 'react-router-dom';
import Layout from "@/pages/layout";
import Login from "@/pages/login";

function Router(props) {
    const { token } = props;
    return (
        <HashRouter>
            <Switch>
                <Route exact path="/login" component={Login} />
                <Route path="/" render={()=> {
                    if (!token) {
                        return <Redirect to="/login" />
                    } else {
                        return <Layout />;
                    }
                }}/>
            </Switch>
        </HashRouter>
    )
}

export default Router;
